package com.heima.search.controller.v1;

import com.heima.common.dtos.ResponseResult;
import com.heima.model.search.dtos.HistorySearchDto;
import com.heima.model.search.pojos.ApUserSearch;
import com.heima.search.Service.ApUserSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 搜索历史
 */
@RestController
@RequestMapping("/api/v1/history")
public class ApUserSearchController {
    @Autowired
    private ApUserSearchService apUserSearchService;

    /**
     * 查询搜索历史
     */
    @PostMapping("/load")
    public ResponseResult<List<ApUserSearch>> load(){
        return apUserSearchService.load();
    }

    /**
     * 删除搜索记录
     */
    @PostMapping("/del")
    public ResponseResult del(@RequestBody HistorySearchDto dto){
        return apUserSearchService.del(dto);
    }
}
